package com.ruantu.clothing.service.impl;

import com.ruantu.clothing.dao.StoreMapper;
import com.ruantu.clothing.entity.PageBean;
import com.ruantu.clothing.entity.SelectStoreResult;
import com.ruantu.clothing.entity.Store;
import com.ruantu.clothing.service.StoreService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/7/25 0025.
 */
@Service
public class StoreServiceImpl implements StoreService {
    @Autowired
    private StoreMapper storeMapper;

    @Override
    public List<Store> findStores(Store store, PageBean pageBean) {
        Map<String, Object> map = new HashMap<>();
        if (StringUtils.isNotBlank(store.getProductCode())) {
            map.put("productCode", store.getProductCode());
        }
        map.put("leixing", store.getLeixing());
        map.put("jgid", store.getJgId());
        map.put("start", pageBean.getStart());
        map.put("rows", pageBean.getRows());
        pageBean.setTotal(storeMapper.findStoresCount(map));
        return storeMapper.findStores(map);
    }

    /**
     *
     * @param jgid
     * @param selectText
     * @param leiXing
     * @param shuLiang
     * @param ordTJ
     * @param pageBean
     * @return
     */
    public List<SelectStoreResult> selectStoreByTJ(String jgid, String selectText, Integer leiXing, Integer shuLiang,String cpYear,String season, String pinpai,Integer ordTJ, PageBean pageBean) {
        pageBean.setTotal(storeMapper.selectStoreByTJCount(jgid, selectText, leiXing, shuLiang,cpYear,season,pinpai,ordTJ));
        return storeMapper.selectStoreByTJ(jgid, selectText, leiXing, shuLiang, cpYear,season,pinpai,ordTJ, pageBean.getStart(), pageBean.getRows());
    }
}
